//
//  TrainManageReasonCell.m
//  Coach_HaiGeEr
//
//  Created by liuchen on 2018/10/15.
//  Copyright © 2018年 海格尔. All rights reserved.
//

#import "TrainManageReasonCell.h"
@interface TrainManageReasonCell()
@property (nonatomic,weak) UIButton *selectBtn;
@property (nonatomic,weak) UILabel *resaonLabel;
@end

@implementation TrainManageReasonCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}

#pragma mark ==========创建视图==========
- (void)createSubView{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundImage:[UIImage imageNamed:@"7-1-5"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"7-1-6"] forState:UIControlStateSelected];
    _selectBtn = btn;
    [self.contentView addSubview:self.selectBtn];
    
    UILabel *reasonLabel = [[UILabel alloc] init];
    reasonLabel.textColor = [UIColor colorWithHexString:@"#282828"];
    reasonLabel.textAlignment = NSTextAlignmentLeft;
    reasonLabel.font = [UIFont systemFontOfSize:LoginFont-3];
    _resaonLabel = reasonLabel;
    [self.contentView addSubview:self.resaonLabel];
    
    //布局
    WS(ws);
    [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws);
        make.left.mas_equalTo(ws).with.offset(100*SCALEUNIT);
        make.width.height.mas_equalTo(32*SCALEUNIT);
    }];
    [self.resaonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.selectBtn.mas_right).with.offset(30*SCALEUNIT);
        make.top.bottom.right.mas_equalTo(ws);
    }];
}

#pragma mark ==========修改状态==========
- (void)setSelectJudge:(BOOL)selectJudge{
    _selectJudge = selectJudge;
    self.selectBtn.selected = !self.selectBtn.selected;
    
}

#pragma mark ==========填充数据==========
- (void)setDic:(NSDictionary *)dic{
    _dic = dic;
    self.resaonLabel.text = [_dic objectForKey:@"name"];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
